package com.xin.di.uav.applet.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xin.di.uav.applet.mapper.TtTesTerminalMapper;
import com.xin.di.uav.applet.po.TtTesTerminal;
import com.xin.di.uav.applet.service.ITtTesTerminalService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.text.Collator;
import java.util.Comparator;
import java.util.List;
import java.util.Locale;

/**
 * <p>
 * 航站信息表 服务实现类
 * </p>
 *
 * @author LTQ
 * @since 2024-04-17
 */
@Service
public class TtTesTerminalServiceImpl extends ServiceImpl<TtTesTerminalMapper, TtTesTerminal> implements ITtTesTerminalService {

    @Autowired
    private TtTesTerminalMapper ttTesTerminalMapper;

    @Override
    public List<TtTesTerminal> getTtTesTerminals() {
        QueryWrapper<TtTesTerminal> ttTesTerminalQueryWrapper = new QueryWrapper<>();
        ttTesTerminalQueryWrapper.eq("delete_label", 1);
        ttTesTerminalQueryWrapper.eq("is_fyps", 1);
        ttTesTerminalQueryWrapper.eq("state", 1);
        List<TtTesTerminal> ttTesTerminals = ttTesTerminalMapper.selectList(ttTesTerminalQueryWrapper);
        Collator collator = Collator.getInstance(Locale.CHINA);
        ttTesTerminals.sort(Comparator.comparing(TtTesTerminal::getAddress, collator));
        return ttTesTerminals;
    }

    @Override
    public List<TtTesTerminal> selectByConnIds(List<String> connIds) {
        return ttTesTerminalMapper.selectList(new QueryWrapper<TtTesTerminal>().in("conn_id", connIds));
    }
}
